<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>用户登录</title>
        <style>
            body {
                font: 13px/20px 'Lucida Grande', Tahoma, Verdana, sans-serif;
                color: #404040;
                background: #e9a2cb;
            }
            .container {
                margin: 80px auto;
                width: 640px;
            }
            .register {
                position: relative;
                margin: 0 auto;
                padding: 20px 20px 20px;
                width: 310px;
                background: white;
                border-radius: 3px;
                box-shadow: 0 0 200px #ffffff80, 0 1px 2px #0000004d;
            }
            .register:before {
                content: '';
                position: absolute;
                top: -8px;
                right: -8px;
                bottom: -8px;
                left: -8px;
                z-index: -1;
                background: #00000014;
                border-radius: 4px;
            }
            .register h1 {
                margin: -20px -20px 21px;
                line-height: 40px;
                font-size: 15px;
                font-weight: bold;
                color: #555;
                text-align: center;
                text-shadow: 0 1px white;
                background: #f3f3f3;
                border-bottom: 1px solid #cfcfcf;
                border-radius: 3px 3px 0 0;
                -webkit-box-shadow: 0 1px whitesmoke;
                box-shadow: 0 1px whitesmoke;
            }
            .register p {
                margin: 20px 0 0;
            }
            .register p:first-child {
                margin-top: 0;
            }
            .register input[type=text], .register input[type=password] {
                width: 278px;
            }
            .register p.remember_me {
                float: left;
                line-height: 31px;
            }
            .register p.remember_me label {
                font-size: 12px;
                color: #777;
                cursor: pointer;
            }
            .register p.remember_me input {
                position: relative;
                bottom: 1px;
                margin-right: 4px;
                vertical-align: middle;
            }
            .register p.submit {
                text-align: right;
            }
            input {
                font-family: 'Lucida Grande', Tahoma, Verdana, sans-serif;
                font-size: 14px;
            }
    
            input[type=text], input[type=password] {
                margin: 5px;
                padding: 0 10px;
                width: 200px;
                height: 34px;
                color: #404040;
                background: white;
                border: 1px solid;
                border-color: #c4c4c4 #d1d1d1 #d4d4d4;
                border-radius: 2px;
                outline: 5px solid #eff4f7;
                -moz-outline-radius: 3px;
                -webkit-box-shadow: inset 0 1px 3px #beacacc8;
                box-shadow: inset 0 1px 3px #beacacc8;
            }
            input[type=text]:focus, input[type=password]:focus {
                border-color: #e9a2cb;
                outline-color: #ffffff;
                outline-offset: 0;
            }
    
            input[type=submit] {
                padding: 0 18px;
                height: 29px;
                font-size: 12px;
                font-weight: bold;
                color: #000000;
                text-shadow: 0 1px #e3f1f1;
                background: #cde5ef;
                border: 1px solid;
                border-color: #b4ccce #b3c0c8 #9eb9c2;
                border-radius: 16px;
                outline: 0;
                -webkit-box-sizing: content-box;
                -moz-box-sizing: content-box;
                box-sizing: content-box;
                background-image: -webkit-linear-gradient(top, #edf5f8, #99d1e9);
                background-image: -moz-linear-gradient(top, #edf5f8, #99d1e9);
                background-image: -o-linear-gradient(top, #edf5f8, #99d1e9);
                background-image: linear-gradient(to bottom, #edf5f8, #99d1e9);
                -webkit-box-shadow: inset 0 1px white, 0 1px 2px rgba(0, 0, 0, 0.15);
                box-shadow: inset 0 1px white, 0 1px 2px rgba(0, 0, 0, 0.15);
            }
            input[type=submit]:active {
                background: #cde5ef;
                border-color: #9eb9c2 #b3c0c8 #b4ccce;
                -webkit-box-shadow: inset 0 0 3px #00000033;
                box-shadow: inset 0 0 3px #00000033;
            }
        </style>
    </head>

<body>
    <script>
        // 获取注册表单元素
        const registerForm = document.getElementById('registerForm');

        // 为表单的提交事件添加监听器
        registerForm.addEventListener('submit', function (e) {
            e.preventDefault(); // 阻止表单默认提交行为，以便进行自定义验证

            // 获取用户名、密码和确认密码输入框的值
            const username = document.getElementById('username').value;
            const password = document.getElementById('password').value;
            const confirmPassword = document.getElementById('confirm_password').value;

            // 进行表单验证
            // 验证用户名是否为空
            if (username === '') {
                alert('用户名不能为空');
                return;
            }

            // 验证密码是否为空
            if (password === '') {
                alert('密码不能为空');
                return;
            }

            // 验证密码和确认密码是否一致
            if (password!== confirmPassword) {
                alert('密码和确认密码不一致');
                return;
            }

            // 如果所有验证都通过，提交表单
            registerForm.submit();
        });
    </script>
    <section class="container">
        <div class="register">
            <h1 class="page-title">用户注册</h1>
            <form id="registerForm" method="post" action="/register">
                <p><input type="text" name="username" id="username" value="" placeholder="用户名"></p>
                <p><input type="password" name="password" id="password" value="" placeholder="密码"></p>
                <p><input type="password" name="confirm_password" id="confirm_password" value="" placeholder="确认密码"></p>
                <a href="login.html">已有账号？点击登录</a>
                <p class="submit"><input type="submit" name="commit" value="注册"></p>
            </form>
        </div>
    </section>
</body>

</html>